//获取应用实例
const app = getApp()
Page({
	data: {
		imgpath:app.setting.apiimgpath,
		flag:true,
		btnFlag:true,
		cancelGoods:'',
		orderTitle:'',
		orderNum:'',
		codevalue:'',
		isData:true
	},
	//核销
	writeOff:function(e){
		wx.navigateTo({
			url:'../writeOff/writeOff?id=' + e.target.dataset.orderid
		})
		this.setData({
			flag:true,
			cancelGoods:e.target.dataset.orderid,
			orderTitle:e.target.dataset.ordertitle,
			orderNum:e.target.dataset.ordernum
		})
	},
	closeAlert:function(){
		this.setData({
			flag:true,
			codevalue:''
		})
	},
	codeInput:function(e){
		this.setData({
			codevalue:e.detail.value
		})
	},
	//确认核销
	trueGoods: function(){
		var that = this;
		if(!that.data.codevalue){
			wx.showToast({
				title:'请输入核销码',
				icon:'none',
			})
			return false;
		}
		//我的订单
		app.request('/api/Goods/cancelGoods', {pwd:that.data.codevalue,orderno:that.data.cancelGoods}, function(res){
			wx.showToast({
				title:res.msg,
				icon:'none'
			})
		});
	},
	onLoad:function(){
		var that = this;
		//我的订单
		app.request('/api/Goods/myExchangeList', {}, function(res){
			if(res.code == '0'){
				//更新数据
				that.setData({
					orderList:res.data
				});
				if(res.data.length == 0){
					that.setData({
						isData:false
					})
				}else{
					that.setData({
						isData:true
					})
				}
			}
		});
	}
})